<?php
	if(!file_exists("cr.php")){
		die("I didn't read the instructions and I deleted the copyright include!");
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<title>Server Stats Page</title>
	
	<style type="text/css">
		<?php
			//Get the theme var
			if(file_exists("settings.php")){
				include "settings.php";
			} else {
				die("Missing settings file!");
			}
			echo "@import \"themes/" . $themename . "/style.css\";";
		?>
	</style>
</head>
<body>
<div id="topbar">
	<p>
		<a href="javascript:document.location.reload();" class="refresh">Refresh</a>
		<span class="spaceme">&nbsp;</span>
		<a href="javascript:;" onclick="if(document.getElementById('onlineplayers').style.display == 'none'){ document.getElementById('onlineplayers').style.display = 'block'; }else{ document.getElementById('onlineplayers').style.display = 'none'; }" class="showonline">Online Players</a>
		<span class="spaceme">&nbsp;</span>
		<a href="javascript:;" onclick="if(document.getElementById('onlinegms').style.display == 'none'){ document.getElementById('onlinegms').style.display = 'block'; }else{ document.getElementById('onlinegms').style.display = 'none'; }" class="showonlinegm">Online GMs</a>
	</p>
</div>
<div id="container">
<div id="onlineplayers">
	<?php
		$onlineplr = simplexml_load_file($statsfile);
		
		foreach($onlineplr->xpath('///plr') as $onlineplrs){
			echo "<p><div class=\"name\">" . $onlineplrs->name . "</div><span class=\"spaceme\">&nbsp;</span><div class=\"online\">" . $onlineplrs->ontime . "</div><span class=\"spaceme\">&nbsp;</span><div class=\"level\">" . $onlineplrs->level . "</div><span class=\"spaceme\">&nbsp;</span><div class=\"map\">" . $onlineplrs->map . "</div></p><br/>";
		}
	?>
</div>
<div id="onlinegms">
	<?php
		$onlinegm = simplexml_load_file($statsfile);
		
		foreach($onlinegm->xpath('///gmplr') as $onlinegms){
			echo "<p>" . $onlinegms->name . "<span class=\"spaceme\">&nbsp;</span>" . $onlinegms->ontime . "<span class=\"spaceme\">&nbsp;</span>" . $onlinegms->permissions . "</p><br/>";
		}
	?>
</div>
<div id="main">
<h2>Server Stats Page for <?php include "settings.php"; echo $servername; ?></h2>
<?php
	if(file_exists("settings.php")){
		include "settings.php";
	}

	if(!$statsfile = simplexml_load_file($statsfile)){
			die("Stats file does not exist!");
		}
		
	if(file_exists("cr.php")) {
		foreach($statsfile->xpath('//status') as $statuss){
			if($showplat == "1"){
				echo "<p><b>Platform: </b>" . $statuss->platform . "</p>";
			} else {}
		
			if($showup == "1"){
				echo "<p><b>Uptime: </b>" . $statuss->uptime . "</p>";
			} else {}
			
			echo "<p><b>GMs Online: </b>" . $statuss->gmcount . "</p>";
		
			$allo = $statuss->alliance+$statuss->horde;
		
			echo "<p><b>Total online: </b>" . $allo . "</p>";
			
			if($showally == "1"){
				echo "<p><b>Alliance online: </b>" . $statuss->alliance . "</p>";
			} else {}
			
			if($showhorde == "1"){
				echo "<p><b>Horde online: </b>" . $statuss->horde . "</p>";
			} else {}
			
			echo "<p class=\"smpl\"><b><small>Last updated: </b>" . $statuss->lastupdate . "</small></p>";
		}
	} else {
			die("I didn't read the instructions and I deleted the copyright include!");
	}

?>
</div>
<div class="clear">&nbsp;</div>
<div id="footer">
	<p>Server Stats Page ~ (c) AlexH</p>
</div>
</body>
</html>
